package com.bph.store.service.impl;

import com.bph.commons.pojo.Store;
import com.bph.commons.pojo.User;
import com.bph.commons.utils.CookieValue;
import com.bph.commons.vo.ResultVo;
import com.bph.store.mapper.StoreMapper;
import com.bph.store.service.StoreService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Service
public class StoreServiceImpl implements StoreService {

    @Resource
    StoreMapper storeMapper;
    @Override
    public ResultVo getStoreBymail(HttpServletRequest request) {
        //获取cookie数组
        CookieValue cookieValue = new CookieValue();
        String user_mail = cookieValue.getCookieValue(request,"mail");

        User user = new User();
        user.setUser_mail(user_mail);
        //先根据mail返回一个store
        Store store = storeMapper.selectStoreByMail(user);

        if(store == null){
            return ResultVo.getFailVo("获取店铺信息失败",2);
        }
        else {
            return ResultVo.getSuccessVo("获取店铺信息成功", store);
        }
    }
}
